// 验证手机
const telphoneReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/
export const telphoneValid = (rule, value, callback) => {
  if (value === '' || value === undefined) {
    callback()
    return
  }

  if (!telphoneReg.test(value)) {
    callback(new Error('请输入正确的手机号码'))
    return
  }
  callback()
}

// 验证座机
const mobphoneReg = /^([0-9]{3,4}-)?[0-9]{7,8}$/
export const mobphoneValid = (rule, value, callback) => {
  if (value === '' || value === undefined) {
    callback()
    return
  }

  if (!mobphoneReg.test(value)) {
    callback(new Error('请输入正确的号码,区号结尾需要加 - '))
    return
  }
  callback()
}
